using Xunit;
using FrameIdentityReq;
using System.Net;

namespace xUnitTest
{
    public class TestCraneParams
    {
        [Fact]
        public void TestName()
        {
            CraneParams aCraneParams = new CraneParams(new string[0]);
            Assert.Equal(IPAddress.Parse("59.110.4.93"), aCraneParams.RemoteIP);
            Assert.Equal(2214, aCraneParams.Port);
            Assert.Equal("0123456789", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("0123456789", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.Equal(2214, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("59.110.4.93"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("127.0.0.1".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(2214, aCraneParams.Port);
            Assert.Equal("0123456789", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("0123456789", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.Equal(2214, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("127.0.0.1 110".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("0123456789", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("0123456789", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("127.0.0.1 110 abcd".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(1024, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("127.0.0.1 110 abcd 4000".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(5, aCraneParams.StartReceiveServiceErrorRetryCount);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal(5, aCraneParams.StartReceiveServiceErrorRetryCount);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("127.0.0.1 110 abcd 4000 10".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(10, aCraneParams.StartReceiveServiceErrorRetryCount);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("127.0.0.1 110 abcd 4000 10".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(10, aCraneParams.StartReceiveServiceErrorRetryCount);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("-RemoteIP 127.0.0.1 110 abcd 4000 10 true".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(10, aCraneParams.StartReceiveServiceErrorRetryCount);
            Assert.True(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.True(aCraneParams.ServerMode);
            Assert.Equal(10, aCraneParams.StartReceiveServiceErrorRetryCount);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("110 abcd -RemoteIP 127.0.0.1 4000 10 true".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.True(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.True(aCraneParams.ServerMode);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("110 abcd 4000 10 true -RemoteIP 127.0.0.1".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.True(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.True(aCraneParams.ServerMode);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);

            aCraneParams = new CraneParams("110 -sendcontent abcd 4000 -RemoteIP 127.0.0.1".Split(' '));
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("5678", aCraneParams.HardwareSerialNum);

            Assert.Equal("5678", aCraneParams.HardwareSerialNum);
            Assert.False(aCraneParams.ServerMode);
            Assert.Equal("abcd", aCraneParams.SendContent);
            Assert.Equal(4000, aCraneParams.BufferSize);
            Assert.Equal(110, aCraneParams.Port);
            Assert.Equal(IPAddress.Parse("127.0.0.1"), aCraneParams.RemoteIP);
        }
    }
}